package cn.edu.nju.askme.model;
// default package

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * PaperAnswer entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="paperanswer"
    ,catalog="askme"
)

public class PaperAnswer  implements java.io.Serializable {


    // Fields    

     private Integer id;
     private User user;
     private Paper paper;
     private Set<Answer> answers = new HashSet<Answer>(0);


    // Constructors

    /** default constructor */
    public PaperAnswer() {
    }

	/** minimal constructor */
    public PaperAnswer(User user, Paper paper) {
        this.user = user;
        this.paper = paper;
    }
    
    /** full constructor */
    public PaperAnswer(User user, Paper paper, Set<Answer> answers) {
        this.user = user;
        this.paper = paper;
        this.answers = answers;
    }

   
    // Property accessors
    @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)

    public Integer getId() {
        return this.id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="uid", nullable=false)

    public User getUser() {
        return this.user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="pid", nullable=false)

    public Paper getPaper() {
        return this.paper;
    }
    
    public void setPaper(Paper paper) {
        this.paper = paper;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="paperAnswer")

    public Set<Answer> getAnswers() {
        return this.answers;
    }
    
    public void setAnswers(Set<Answer> answers) {
        this.answers = answers;
    }
   








}